// 统计字符串中每个字符出现的次数
const str = "ddfdflekdfdsfeeeereeeeeeeeeeekfjdsfkdsfj";

const result = {};
for (let i = 0; i < str.length; i++) {
  if (result[str[i]]) {
    result[str[i]]++;
  } else {
    result[str[i]] = 1;
  }
}

console.log(result);

const arr=str.split("");

const res=arr.reduce((prev,cur)=>{
  if(prev[cur]){
    prev[cur]++;
  }else{
    prev[cur]=1;
  }
  return prev;
},{})
console.log(res);